﻿using System.Linq.Expressions;

namespace DongFangGuoKai.WMSPlatform.Core.Repository
{
    public interface IRepository<TEntity> where TEntity : class
    {
        bool Any(Expression<Func<TEntity, bool>> predicate);
        int Count(Expression<Func<TEntity, bool>> predicate);
        Task<int> CountAsync(Expression<Func<TEntity, bool>> predicate);
        bool Delete(Expression<Func<TEntity, bool>> predicate);
        bool Delete(TEntity entity);
        bool DeleteRange(IEnumerable<TEntity> entities);
        Task<bool> DeleteAsync(TEntity entity);
        TEntity Get(Expression<Func<TEntity, bool>> predicate);
        Task<TEntity> GetAsync(Expression<Func<TEntity, bool>> predicate);
        WMSPlatformContext GetContext();
        List<TEntity> GetList();
        List<TEntity> GetList(Expression<Func<TEntity, bool>> predicate);
        List<TEntity> GetList(Expression<Func<TEntity, bool>> predicate, Expression<Func<TEntity, object>> sort, int pageIndex, int pageSize, bool isAsc = true);
        List<TEntity> GetList(Expression<Func<TEntity, bool>> predicate, string sort, int pageIndex, int pageSize, bool isAsc = true);
        List<TEntity> GetList(string sort, int pageIndex, int pageSize, bool isAsc = true);
        Task<List<TEntity>> GetListAsync();
        Task<List<TEntity>> GetListAsync(Expression<Func<TEntity, bool>> predicate);
        Task<List<TEntity>> GetListAsync(Expression<Func<TEntity, bool>> predicate, Expression<Func<TEntity, object>> sort, int pageIndex, int pageSize, bool isAsc = true);
        Task<List<TEntity>> GetListAsync(Expression<Func<TEntity, bool>> predicate, string sort, int pageIndex, int pageSize, bool isAsc = true);
        Task<List<TEntity>> GetListAsync(string sort, int pageIndex, int pageSize, bool isAsc = true);
        IQueryable<TEntity> GetQueryable();
        TEntity Insert(TEntity entity);
        List<TEntity> InsertRange(List<TEntity> entities);
        Task<TEntity> InsertAsync(TEntity entity);
        bool Update(TEntity entity);
        bool TryUpdateModel(TEntity tEntity, params string[] updateFiled);
        Task<bool> UpdateAsync(TEntity entity);
    }
}